<template>
  <div >
    <!--    <img alt="Vue logo" src="../assets/logo.gif">-->
    <!--最外层容器-->
    <el-container>
      <!--      上半部分:顶栏-->
      <el-header class="layout-header">
        <div id="huanyin"><h1>欢迎进入体育局体育产业基地管理信息系统</h1></div>
        <div id="welcome">
          <span >欢迎用户  {{loginname}}  回家      </span>
          <el-button type="primary"  @click="exit">退出</el-button>
        </div>

      </el-header>
      <!--      下半部分:容器-->
      <el-container class="layout-body">
        <!--        下半部分的左侧边栏-->
        <el-aside class="layout-aside">
          <!--router.currentRoute.path 路由器.当前路由.路径-->
          <el-menu
              router
              :default-active="$router.currentRoute.path"
              class="el-menu-vertical-demo"
              background-color="#222c32"
              text-color="#fff"
              active-text-color="#ffd04b">
            <!-- 首页 -->
            <el-menu-item index="/tiyu">
              <i class="el-icon-s-home"></i>
              <span>首页</span>
            </el-menu-item>
            <!-- 项目申报 -->
            <el-submenu index="2" v-if="power1">
              <template slot="title">
                <i class="el-icon-s-goods"></i>
                <span>项目申报</span>
              </template>
              <el-menu-item index="/tiyuju/project-declaration/projectaudit" >
                <i class="el-icon-s-grid"></i>
                <span slot="title">示范项目申报信息</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/project-declaration/baseaudit">
                <i class="el-icon-s-grid"></i>
                <span slot="title">示范基地申报信息</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/project-declaration/SUnitDeclaration">
                <i class="el-icon-s-grid"></i>
                <span slot="title">示范单位申报信息</span>
              </el-menu-item>
            </el-submenu>
            <!-- 申报信息审核 -->
              <el-submenu index="3" v-if="power2">
              <template slot="title">
                <i class="el-icon-s-order"></i>
                <span>申报信息审核</span>
              </template>
              <el-menu-item index="/tiyuju/information-moderation/projectaudit">
                <i class="el-icon-s-grid"></i>
                <span slot="title">项目申报信息审核</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/information-moderation/baseaudit">
                <i class="el-icon-s-grid"></i>
                <span slot="title">基地申报信息审核</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/information-moderation/Unitaudit">
                <i class="el-icon-s-grid"></i>
                <span slot="title">单位申报信息审核</span>
              </el-menu-item>

            </el-submenu>
            <!-- 申报用户管理 -->
            <el-menu-item index="/user/UserManage" v-if="power">
              <i class="el-icon-s-home"></i>
              <span>申报用户管理</span>
            </el-menu-item>
            <!-- 系统管理 -->
            <el-submenu index="5" v-if="power">
              <template slot="title">
                <i class="el-icon-s-shop"></i>
                <span>系统管理</span>
              </template>
              <el-menu-item index="/tiyuju/internal_unit">
                <i class="el-icon-s-grid"></i>
                <span slot="title">内部单位管理</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/information-moderation/roleList">
                <i class="el-icon-s-grid"></i>
                <span slot="title">角色管理</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/information-moderation/UserManagement">
                <i class="el-icon-s-grid"></i>
                <span slot="title">内部用户管理</span>
              </el-menu-item>
              <el-menu-item index="/tiyuju/userLogLogin">
                <i class="el-icon-s-grid"></i>
                <span slot="title">登陆日志管理</span>
              </el-menu-item>
            </el-submenu>
            <!-- 通知公告 -->
            <el-menu-item index="/notification-announcement" v-if="power">
              <i class="el-icon-s-check"></i>
              <span>通知公告</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <!--        下半部分的右侧主体部分-->
        <el-main class="layout-main">
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loginname:"",
      power:false,
      power1:false,
      power2:false,
    };
  },
  created() {


  },
  mounted() {
    let role = this.cookie.getCookie("role");
    console.log("首页 角色"+role)
    if (role=="普通用户"){
      this.power1=true
    } else if (role=="审核员"){
      this.power2=true
    }else{
      this.power=true
      this.power1=true
      this.power2=true
    }
    if (location.href.indexOf("#reloaded") == -1) {
      location.href = location.href + "#reloaded";
      location.reload();
    }
    this.loginname=this.cookie.getCookie("LoginName");
  },
  methods:{
    logout(){
      //调用this.cookie.clearCookie方法删除cookie
      this.cookie.clearCookie("LoginName");
      this.cookie.clearCookie("openId");
      this.cookie.clearCookie("role");

    },
    //退出
    exit(){
      //跳转Login页面
      this.$confirm("即将退出登录,是否继续?","提示",{
        confirmButtonText:"确定",
        cancelButtonText:"取消",
        type:"warning",
      })
      .then(()=>{
        this.logout();
        this.$message({
          type:"success",
          message:"退出成功!",
        });
        this.$router.replace('/Login');
      })
      .catch(()=>{
        this.$message({
          type:"info",
          message:"已取消退出",
        });
      });
    }
  }
}
</script>

<style>
.layout-header {
  background: #1684b0;
}
.layout-header h1 {
  color: #fff;
  text-align: left;
  line-height: 60px;
}
.layout-body {
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;}
.layout-aside {
  background-color:#222c32;
}
.layout-aside i{
  color: #fff !important;
  width: 200px;
}
.layout-main {
}
.el-menu-item.is-active{
  background: #2d3c4d !important;
}
#welcome{
  margin-top: 8px;
  display: inline-block;
  float: right;
}
#huanyin{
  /*line-height: 50px;
  margin-top: 6px;
  color: #fff;
  font-size: 30px;*/
  display: inline-block;

}
</style>

